package com.ccrfid.rmc6.pojo.dto.visitroom;

import com.ccrfid.rmc6.appconfig.jackson.CustomDouble4Serialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.util.List;

public class PrisonAreaDto {
    private Long orgId;
    private String orgName;
    private String orgSn;
    private Integer sortNumber;
    @JsonSerialize(using = CustomDouble4Serialize.class)
    private Double completionRate;
    private List<PrisonRoomDto> prisonRoomList;

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public String getOrgName() {
        return orgName;
    }

    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }

    public String getOrgSn() {
        return orgSn;
    }

    public void setOrgSn(String orgSn) {
        this.orgSn = orgSn;
    }

    public Integer getSortNumber() {
        return sortNumber;
    }

    public void setSortNumber(Integer sortNumber) {
        this.sortNumber = sortNumber;
    }

    public Double getCompletionRate() {
        return completionRate;
    }

    public void setCompletionRate(Double completionRate) {
        this.completionRate = completionRate;
    }

    public List<PrisonRoomDto> getPrisonRoomList() {
        return prisonRoomList;
    }

    public void setPrisonRoomList(List<PrisonRoomDto> prisonRoomList) {
        this.prisonRoomList = prisonRoomList;
    }

    public void calcCompletionRate() {
        if (prisonRoomList != null && prisonRoomList.size() > 0) {
            double sum = 0.0;
            for (PrisonRoomDto roomDto : prisonRoomList) {
                sum += roomDto.getCompletionRate();
            }
            this.completionRate = sum / prisonRoomList.size();
        } else {
            this.completionRate = 0.0;
        }
    }
}
